import SwiftUI

/*
 * 表格示例
 */
class GridExample: FCUIView{
    /*
     * 点击单元格事件
     */
    func onClickGridCell(grid:FCGrid, row:FCGridRow, gridColumn:FCGridColumn, cell:FCGridCell, firstTouch:Bool, firstPoint:FCPoint, secondTouch:Bool, secondPoint:FCPoint, clicks:Int){
    }
    
    /*
     * 初始化布局
     */
    override func onLoad(){
        let isInit = super.m_isInit
        super.onLoad()
        if !isInit{
            m_paint.defaultUIStyle = "light"
            let width = Double(self.frame.size.width), height = Double(self.frame.size.height)
            renderFaceCat(name:"gridexample", paint: m_paint, size: FCSize(cx:width, cy:height))
            m_paint.addClickGridCellEvent(callBack: onClickGridCell)
            let grid = findViewByName(name:"Grid", views:m_paint.views) as! FCGrid
            for i in 0...100{
                let row = FCGridRow()
                grid.rows.append(row);
                for _ in 0...2{
                    let cell = FCGridCell()
                    cell.value = "Cell" + String(i)
                    row.cells.append(cell)
                }
            }
            invalidate(paint:m_paint)
        }
    }
}
